\documentclass[useAMS,usenatbib,]{mn2e}
%\documentclass[referee,useAMS,usenatbib]{mn2e}
\usepackage{times}
\usepackage{natbib}
\usepackage[dvips]{graphicx}
%\usepackage{subfigure}
%\usepackage{multirow}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\DeclareGraphicsRule{.bmp}{bmp}{}{}

\newcommand{\aj}{AJ}
\newcommand{\apj}{ApJ}
\newcommand{\apjl}{ApJ}
\newcommand{\apjs}{ApJS}
\newcommand{\aap}{A\&A}
\newcommand{\aaps}{A\&AS}
\newcommand{\mnras}{MNRAS}
\newcommand{\nat}{Nature}
\newcommand{\araa}{ARAA}
\newcommand{\prd}{Phys. Rev. D}
\newcommand{\pasj}{PASJ}
\newcommand{\pasp}{PASP}
\newcommand{\physrep}{Phys. Rep.}

\title[]
{Cosmological MHD SPH implementations applied to Galaxy Clusters}
\author[F. Stasyszyn,K. Dolag]
{F. Stasyszyn$^{1}$\thanks{E-mail: fstasys@mpa-garching.mpg.de},
K. Dolag$^{1}$\\
$^{1}$ Max-Planck-Institut f\"ur Astrophysik, Garching, Germany
}
\begin{document}

\date{Accepted ???. Received ???; in original form ???}

%\pagerange{\pageref{firstpage}--\pageref{lastpage}} \pubyear{0000}

\maketitle

\label{firstpage}

\begin{abstract}
Various observations have shown that the hot atmospheres of
galaxy clusters are magnetized. However, our understanding of the
origin of these magnetic fields, their implications on structure
formation and their interplay with the dynamics of the cluster
atmosphere, especially in the centers of galaxy clusters is still
very limited. 
%In preparation for the upcoming new generation of
%radio telescopes (like EVLA, LWA, LOFAR and SKA), a huge effort is
%being made to learn more about cosmological magnetic fields from
%the observational perspective. Here we present the implementation
%of magneto-hydrodynamics in the cosmological SPH code GADGET
%\citep{springel2001,springel2005}. We discuss the details of the
%implementation and various schemes to suppress numerical
%instabilities as well as regularization schemes, in the context of
%cosmological simulations. The performance of the SPH-MHD code is
%demonstrated in various one and two dimensional test problems,
%which we performed with a fully, three dimensional setup to test the
%code under realistic circumstances. Comparing solutions
%obtained using ATHENA \citep{2008arXiv0804.0402S}, we find
%excellent agreement with our SPH-MHD implementation. Finally we
%apply our SPH-MHD implementation to galaxy cluster formation within
%a large, cosmological box. Performing a resolution study we
%demonstrate the robustness of the predicted shape of the magnetic
%field profiles in galaxy clusters,  which is in good agreement
%with previous studies.
\end{abstract}

\begin{keywords}
(magnetohydrodynamics)MHD - magnetic fields - methods: numerical - galaxies: clusters
\end{keywords}

%##################################################################################
%########################## Introduction ##########################################
%##################################################################################

\section{Introduction} \label{sec:intro}

%##################################################################################
%########################## Introduction ##########################################
%##################################################################################

\section{Sph MHD Implementation}


\subsection{SPH implementation in GADGET} \label{sec:code}
%\citep{2004MNRAS.348.1078B}
MHD

\begin{equation}
	\frac{d\rho}{dt}=-\rho\nabla\cdot {\bf v}  
\end{equation}
\begin{equation}
	\frac{dv^{i}}{dt}=\frac{1}{\rho} \frac{\delta S^{ij}}{\delta x^j}  
\end{equation}
\begin{equation}
	\frac{du}{dt}=-\frac{P}{\rho} \nabla\cdot {\bf v}
\end{equation}
\begin{equation}
	\frac{d{\bf B}}{dt}=({\bf B} \cdot \nabla) {\bf v}-{\bf B } (\nabla\cdot {\bf v})
\end{equation}
Streess tensor
\begin{equation}
	{\bf{S}^{ij}}=-P\delta^{ij}+\frac{1}{{\mu}_0}\left(B^iB^j-\frac{1}{2}B^2\delta^{ij} \right)
\end{equation}

Cosmological cordenates

\begin{equation}
	\frac{\dot{a}}{a}=H_0  
\end{equation}
BASE
\begin{eqnarray}
	\omega = a^2 V_{com} \nonumber \\
	\eta = log(a) \nonumber \\
	d\eta = \frac{da}{a} \nonumber \\
	X_{phi} =a \cdot X_{com} \nonumber \\
	V_{phi} =a \cdot V_{com} \nonumber \\
	\rho_{phi} = \frac{\rho_{com}}{a^3}	
\end{eqnarray}
\begin{eqnarray}
	H(z) = \frac{\dot{a}}{a} \nonumber\\
	\dot{a} = H(z) \cdot a = \frac{da}{dt} \nonumber \\
	H(z) \cdot dt = d\eta \\
	\frac{\omega}{a} = V_{phi} 
\end{eqnarray}
Induction eq
\begin{eqnarray}
 \frac{\delta{\bf B_p}}{\delta t}=\nabla \times ({\bf v_p} \times {\bf B_p})  \nonumber 
\end{eqnarray}
but...
\begin{eqnarray}
 \frac{d{\bf B_p}}{dt} = \frac{\delta{\bf B_p}}{\delta t} + {\bf v_p} \cdot \nabla {\bf B_p} \nonumber  
\end{eqnarray}
and
\begin{eqnarray}
  {\bf B_p} = \frac{{\bf B_c}}{a^2}
\end{eqnarray}
so...
\begin{eqnarray}
 \frac{d{\bf B_p}}{dt} = \frac{d{\bf B_c}}{dt}\frac{1}{a^2}- {2 H(z){\bf B_p}} \nonumber  \\
\end{eqnarray}
but 
\begin{eqnarray}
  \frac{d{\bf B_c}}{dt} = ({\bf B_c}\cdot \nabla_c) {\bf v_c} - {\bf B_c}(\nabla_c \cdot {\bf v_c})  \nonumber  \\
\end{eqnarray}
so...
\begin{eqnarray}
 \frac{d{\bf B_p}}{dt} = \frac{1}{a^2} \left(({\bf B_c}\cdot \nabla_c) {\bf v_c} - {\bf B_c}(\nabla_c \cdot {\bf v_c})\right) - {2 H(z){\bf B_p}} \nonumber  \\
 H(z)\frac{d{\bf B_p}}{d\eta} = \frac{1}{a^2} \left(({\bf B_p}\cdot \nabla_c) {\bf \omega} - {\bf B_p}(\nabla_c \cdot {\bf \omega})\right) - {2 H(z){\bf B_p}} \nonumber  \\
 \frac{d{\bf B_p}}{d\eta} = \frac{1}{H(z)a^2} \left(({\bf B_p}\cdot \nabla_c) {\bf \omega} - {\bf B_p}(\nabla_c \cdot {\bf \omega})\right) - {2 {\bf B_p}} \nonumber  
\end{eqnarray}
voila! the induction ecuation for the $B_p$.... that's the one that we evolve in Gadget.


\subsection{Co-moving variables and integration}

\section{Divergence}

Is not the devil 

\subsection[Regularization]{Regularization schemes} \label{sec:reg}

Art.Diss or Bsmooth see klaus

\subsection{Divergence Cleaning} \label{sec:ded}

Dedner:
\begin{equation}
	{\frac{d{\bf B_p}}{dt}}^{Dedner} = -\nabla_p \phi_p
	\label{eq:dBtphi0}
\end{equation}

Here only we show the term that we have to add to the induction ecuation.

Also one has to take into account the fact that $\nabla \cdot {\bf B}$ do not vanish and the 
changes in the energy introduced by this artifitial magnetic field in the energy ecaution.

\begin{eqnarray}
	\frac{d{\bf v}}{dt} = - (\nabla \cdot {\bf B_p}){\bf B_p} \\
	\frac{d{\bf v}}{d\eta} = - a^{3\gamma} \frac{(\nabla_c \cdot {\bf B_p}){\bf B_p}}{a H(z)} \\
	\frac{du}{dt} = - {\bf B_p} \cdot (\nabla_p \phi_p) \\
	\frac{dA}{d\eta} = - \frac{\gamma-1}{\rho^{\gamma-1}}\frac{{\bf B_p} \cdot (\nabla_c \phi_p)}{a H(z)} 
	\label{eq:dudtphi0}
\end{eqnarray}
theses previous eq should be checked
now, for the evolution of $\phi$
\begin{equation}
	\frac{d\phi_p}{dt} = 
	-\left({c_h}^2 \nabla_p \cdot {\bf B_p} + \frac{{c_h}^2 }{{c_p}^2} \phi_p \right) 
	\label{eq:dtphi0}
\end{equation}
 but Price suggest to use:
\begin{eqnarray}
  {c_h}^2 = \pi {c_s}^2 		\nonumber \\
  \frac{{c_h}^2}{{c_p}^2} = \frac{\sigma c_s}{\lambda} \\
\end{eqnarray}
 where $c_s$ is the sound/signal velosity, and $\sigma$ and $\pi$ are dimesntionless parameters to be chosen or adjusted depending on the problems.

so equation \ref{eq:dtphi0} takes que form of
\begin{equation}
	\frac{d\phi_p}{dt} = 
	-\left(\pi {c_s}^2 \nabla_p \cdot {\bf B_p} + \frac{\sigma c_s}{\lambda} \phi_p \right) 
	\label{eq:dtphi1}
\end{equation}
 
 mostly taking UNIT considerations... 

Now following to take into account the Comoving integration one has for equation \ref{eq:dBtphi0}, to obtain the same kind of derivation as the induction eq used in gadget.
\begin{eqnarray}
	\left[ \phi_p \right] = {[Magnetic Field]}_p \cdot [Velocity]_p 			\nonumber \\ 
	\left[ \phi_p \right] = \frac{{[Magnetic Field]}_c}{a} \cdot [Velocity]_c = \frac{[\phi_c]}{a} \\
	\left[ \phi_p \right]= \frac{{[Magnetic Field]}_c}{a^3} \cdot [\omega] = \frac{[\phi_gadget]}{a^3} 
\end{eqnarray}

\begin{equation}
	{\frac{d {\bf B_p}}{d\eta}}^{Dedner} = \frac{-\nabla_c \phi_p}{a H(z)}
\end{equation}

and for the evolution of $\phi$

\begin{eqnarray}
	\frac{d\phi_p}{dt} = \frac{1}{a} \frac{d\phi_c}{dt} - \frac{H(z)\phi_c}{a} \nonumber \\
	\frac{d\phi_c}{dt} = - \pi {c_c}^2 \nabla_c \cdot {\bf B_c} -	
		               \frac{\sigma c_c}{ \lambda_c} \phi_c 		\nonumber     \\
	\frac{d\phi_p}{dt} = - \frac{1}{a} \left( 
 			\pi {c_c}^2 \nabla_c \cdot {\bf B_c} + \frac{\sigma c_c }{ \lambda_c } \phi_c 
				\right) - H(z)\phi_p 			\\
	\frac{d\phi_p}{dt} = -  \left( 
 			\pi \frac{{\omega_s}^2}{a^3} \nabla_c \cdot {\bf B_p} + 
			\frac{\sigma \omega_s }{a \lambda_c } \phi_p 	\right) - H(z)\phi_p \\ 
	\frac{d\phi_p}{d\eta} = - \frac{1}{H(z)} \left( 
 		\pi \frac{{\omega_s}^2}{a^3} \nabla_c \cdot {\bf B_p} + 
		\frac{\sigma \omega_s }{a \lambda_c } \phi_p 	\right) - \phi_p
\end{eqnarray}
%\begin{eqnarray}
%	\frac{d\phi_c}{dt} = - {\pi {c_c}^2 \nabla_c \cdot {\bf B_c}} -	
%		             \frac{\sigma c_c}{ \lambda_c} \phi_c 		\nonumber     \\
 %       \frac{d\phi_c}{dt} = -\frac{\pi {c_s}^2 \nabla_c \cdot {\bf B_p}} {a} -	
%		             \frac{\sigma c_s}{ a \lambda_c} \phi_c 		\nonumber     \\
%        \frac{d\phi_c}{dt} = -\frac{\pi {c_s}^2 \nabla_c \cdot {\bf B_p}} {a} -	
%		             \frac{\sigma c_s}{ \lambda_c} \phi_p 		\nonumber     \\
%\end{eqnarray}
Note that the $c_s$ is always in physical units and $c_c$ is the sound speed in comoving units.
\begin{eqnarray}
	\frac{d\phi_p}{d\eta} = \frac{1}{H(z) a} \frac{d\phi_c}{dt} - {3 \phi_p} \nonumber \\
	\frac{d\phi_p}{d\eta} = -\frac{1}{H(z) a} \left( \frac{\pi {c_s}^2 \nabla_c \cdot {\bf B_p}} {a} -   \frac{\sigma c_s}{\lambda_c} \phi_p \right) - {3 \phi_p} \nonumber \\
\end{eqnarray}

\subsection{Scalar and Vector Projections} \label{sec:proj}

\subsection{Euler potential} \label{sec:eul}

In these case the Magnetic field is calculated using 2 scalar portentials perpendicular to the field lines.

\begin{equation}
	{\bf B_p} = \nabla_p \alpha_p \times \nabla_p \beta_p  
\end{equation}
Were in particular $\alpha$ and $\beta$ are advected with the flow, it means
\begin{eqnarray}
	\frac{d\alpha}{dt} = 0 \nonumber \\
	\frac{d\beta} {dt} = 0 \nonumber 
\end{eqnarray}

\subsection{Vector potential} \label{sec:vct}

In this case the Magnetic field is computed as the rotor of Vector Potential
%\begin{equation}
%\end{equation}
\begin{eqnarray}
	{\bf B} = \nabla \times {\bf  A} \\
	\frac{\delta A}{\delta t} = {\bf v_p} \times {\bf B_p}
\end{eqnarray}

and the evolution of $ A $ is given by

\begin{eqnarray}
 \frac{d{\bf A_p}}{dt} = \frac{\delta{\bf A_p}}{\delta t} + {\bf v_p} \cdot \nabla {\bf A_p} \nonumber \\ 
 \frac{d{\bf A_p}}{dt} = {\bf v_p} \times {\bf B_p} + {\bf v_p} \cdot \nabla {\bf A_p} \nonumber  
%	{\bf B} = \nabla \times {\bf  A}
%	\frac{\delta A}{\delta t} = {\bf v_p} \times {\bf B_p}
\end{eqnarray}



\section{Comparation and Test} \label{sec:test}

\begin{figure}
 \includegraphics[height=0.30\textwidth]{plt/test.DedVsNrm.ps}
 \label{fig:Test}
\caption{Comparation of several Tests}
\end{figure}
\begin{figure}
 \includegraphics[height=0.30\textwidth]{plt/tests/5A_norm.ps}
 \includegraphics[height=0.30\textwidth]{plt/tests/5A_dedn.ps}
 \label{fig:Shock}
\caption{Dedner vs Nomral in Brio-Wu shock tube test}
\end{figure}

\begin{figure*}
 \includegraphics[height=0.30\textwidth]{plt/tests/vor_ded.divb.ps}
 \includegraphics[height=0.30\textwidth]{plt/tests/vor_ded.rho.ps} \\
 \includegraphics[height=0.30\textwidth]{plt/tests/vor_nnn.divb.ps}
 \includegraphics[height=0.30\textwidth]{plt/tests/vor_nnn.rho.ps}
 \label{fig:Vortex}
\caption{Normal Vortex vs the Dedner Implementation}
\end{figure*}




\section{Cosmological Application} \label{sec:sim}

:%##################################################################################
%########################## Conclusions ###########################################
%##################################################################################

\section{Conclusions} \label{sec:conc}


%##################################################################################
%########################## Acknowledgements / Bibliography #######################
%##################################################################################

\section*{acknowledgements}

\bibliographystyle{mn2e}
\bibliography{master}

\appendix

\end{document}
